<!DOCTYPE html>
<html lang="en">
<head>
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="yes" name="apple-touch-fullscreen">
    <meta content="telephone=no,email=no" name="format-detection">
    <meta name="wap-font-scale" content="no">
    <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title><?=$title?></title>
    <link rel="stylesheet" href="/mobile/css/reset.css">
    <link rel="stylesheet" href="/mobile/css/mui.min.css">
    <link rel="stylesheet" href="/mobile/css/dropload.css">
    <script src="/mobile/js/flexible_css.debug.js"></script>
    <script src="/mobile/js/flexible.debug.js"></script>
    <link rel="stylesheet" href="/mobile/css/main_train.css">

</head>
<body>
<div id="back-btn-wrap">
    <a class="back-btn" href="javascript:void(0)"></a>培训发布
</div>
<p class="sm-tips" >如您对我们的培训项目感兴趣，请留言给我们</p>
<div class="content-main clearfix" id="sm-wrap">
    <div class="sm-msg-wrap"></div>
</div>
<div class="send-tool-wrap">
    <textarea name="" id=""></textarea>
    <span class="msg-send-btn">发送</span>
</div>

<script src="/mobile/js/jquery.min.js"></script>
<script src="/mobile/js/dropload.js"></script>
<script src="/mobile/js/common.js"></script>
<script src="/mobile/js/mui.min.js"></script>
<script src="/mobile/js/jrrpc.js"></script>
<script src="/mobile/js/autosize.js"></script>

<script>
    $(function(){
        mui.init();
        var flag = iService.getQueryString('flag');
        $('.back-btn').on('click',function(){
            if(flag){
                if(iService.getUserAgent().isiOS){
                    webBack();
                }else if(iService.getUserAgent().isAndroid){
                    h5button.webBack();
                }
            }else {
                window.history.go(-1)
            }
        });

        var token = iService.getAppParam();
        $('textarea').autosize();
        iService.iosInput();
        function getMsgList(page,me){
            var param = {
                postData:'Demand/lists',
                data:{
                    page:page
                }
            };
            $.extend(param.data,token);
            $.JsonRpc(param,function(result){
                console.log(result);
                var data = result.data;
                if(!smWrap.attr('data-page')){
                    smWrap.attr('data-page',result.data.count);
                }
                $.each(data.lists,function(i){
                    $(
                        '<div class="msg-item">'+
                        '<div class="time-wrap">'+
                        '<span class="msg-time">'+data.lists[i].createtime+'</span>'+
                        '</div>'+
                        '<div class="msg-info">'+
                        '<span class="avatar fl" style="background: url('+data.lists[i].avatar+') no-repeat center center; background-size: cover;"></span>'+
                        '<p class="nickname">'+data.lists[i].nickname+'</p>'+
                        '<div class="msg-wrap">'+data.lists[i].content+'</div>'+
                        '</div>'+
                        '</div>'
                    ).prependTo('.sm-msg-wrap');
                });
                if(me){
                    me.resetload();
                }
            },me);
        }

        var page = 1;
        getMsgList(page);
        var smWrap = $('#sm-wrap');

        $('#sm-wrap').dropload({
//          滑动区域
            scrollArea: window,
//          autoLoad:false,
//          定义上方样式
            domUp: {
                domClass: "dropload-up",
                domRefresh: '<div class="dropload-refresh">↓下拉加载更多</div>',
                domUpdate: '<div class="dropload-update">↑释放加载</div>',
                domLoad: '<div class="dropload-load"><span class="loading"></span>加载中...</div>'
            },
            distance: 50,
            threshold: "",
            loadUpFn: function(me){
                page += 1;
                if(page<=Math.ceil(smWrap.attr('data-page')/3)){
                    getMsgList(page,me);
                }else {
                    me.lock();//没有更多数据
                    me.noData();//没有更多数据
                    me.resetload();
                }
            }
        });

        mui('.send-tool-wrap').on('tap','.msg-send-btn',function(){
            var content = $('textarea').val();
            if(!content){
                return false;
            }
            var req = {
                postData:'Demand/add',
                data:{
                    content:content
                }
            };
            $.extend(req.data,token);
            $.JsonRpc(req,function(result){
                console.log(result);
                window.location.reload();
                $(
                    '<div class="msg-item msg-item-right">'+
                        '<div class="time-wrap">'+
                            '<span class="msg-time">刚刚</span>'+
                        '</div>'+
                        '<div class="msg-info">'+
                            '<span class="avatar fr" style="background: url('+df+') no-repeat center center;"></span>'+
                            '<p class="nickname fr">昵称app给</p>'+
                            '<br />'+
                            '<div class="msg-wrap fr">'+content+'</div>'+
                        '</div>'+
                    '</div>'
                ).appendTo('#sm-wrap')

            });
        });
        $.get('https://www.wzxaini9.cn/api/flow/index/id/11', function (data) {
            console.log($.parseJSON(data));
        })
    });
</script>
</body>
</html>












